import 'dart:ui';

import 'package:flutter/material.dart';
import 'res/listData.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("有点麻烦"),
        ),
        body: HomeContent(),
      ),
    );
  }
}

class HomeContent extends StatelessWidget {
  List getWidget() {

    List <Widget> mList = new List();
    for (var i = 0; i < mListData.length; i++) {
      
      mList.add(ListTile(
        leading: Image.network(mListData[i]["imageUrl"]),
        title: Text(mListData[i]["title"]),
        subtitle: Text(mListData[i]["author"]),
      ));
      
    }
   return mList;

    // var mList = mListData.map((value) {
    //   return ListTile(
    //     leading: Image.network(value["imageUrl"]),
    //     title: Text(value["title"]),
    //     subtitle: Text(value["author"]),
    //   );
    // });
    // return mList.toList();
  }

  @override
  Widget build(BuildContext context) {
    return ListView(children: getWidget());
  }
}
